package com.thinkgem.jeesite.modules.qy.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by JohnShen on 2016/12/2.
 * 验证用的工具类
 */
public class VerificationTools {

    /**
     * 验证邮件名是否合法
     * @param email  邮件
     * @return
     */
    public static  boolean vaideEamil(String email){
        Pattern pattern = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
        Matcher matcher = pattern.matcher(email);
        return  matcher.matches();
    }

    /**
     * 验证手机号码是否符合规范
     * @param mobile  手机号码
     * @return
     */
    public static boolean vaideMobile(String mobile){
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
        Matcher m = p.matcher(mobile);
        return m.matches();
    }
}
